package star.cloud.asme.base.fowable.baseInterface;

import com.baomidou.mybatisplus.core.metadata.IPage;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import star.cloud.asme.base.dto.Result;

import java.util.List;

@RestController
public interface FlowableBaseController<Q extends FlowableBaseQueryCondition, R extends FlowableBaseEntity> {

    @GetMapping("/getOneByCondition/{key}/{value}")
    default Result<R> getOneByCondition(@PathVariable("key") String key, @PathVariable("value") Object value) {
        System.out.println(key);
        System.out.println(value);
        return Result.error();
    }

    @PostMapping("/getOneByConditions")
    default Result<R> getOneByConditions(Q conditions) {
        System.out.println(conditions);
        return Result.error();
    }

    @GetMapping("/getListByCondition/{key}/{value}")
    default Result<List<R>> getListByCondition(@PathVariable("key") String key, @PathVariable("value") Object value) {
        System.out.println(key);
        System.out.println(value);
        return Result.error();
    }

    @PostMapping("/getListByConditions")
    default Result<List<R>> getListByConditions(Q conditions) {
        System.out.println(conditions);
        return Result.error();
    }

    @PostMapping("/getListByConditionsWithPage")
    default Result<IPage<R>> getListByConditionsWithPage(Q conditions) {
        System.out.println(conditions);
        return Result.error();
    }

    @PostMapping
    default Result<R> insertOne(R entity) {
        System.out.println(entity);
        return Result.error();
    }

    @PutMapping
    default Result<R> updateOne(R entity) {
        System.out.println(entity);
        return Result.error();
    }

    @PreAuthorize("hasRole('超级管理员')")
    @DeleteMapping("/physical/{id}")
    default Result<?> physicalDeleteById(@PathVariable("id") String id) {
        System.out.println(id);
        return Result.error();
    }

    @DeleteMapping("/logical/{id}")
    default Result<?> logicalDeleteById(@PathVariable("id") String id) {
        System.out.println(id);
        return Result.error();
    }
}
